<?php  
class ControllerModuleNivoSlider extends Controller {
	protected function index($setting) {
		static $module = 0;
		
		$this->load->model('design/banner');
		$this->load->model('tool/image');
		
		$theme = $this->config->get('nivo_slider_theme');
		
		$this->document->addScript('catalog/view/javascript/jquery/nivo-slider/jquery.nivo.slider.transparent.pack.js');
		$this->document->addStyle('catalog/view/javascript/jquery/nivo-slider/themes/' . $theme . '/' . $theme . '.css');
		$this->document->addStyle('catalog/view/javascript/jquery/nivo-slider/nivo-slider.css');
		
		$this->data['nivo_slider_theme'] = $theme;
		$this->data['nivo_slider_featured'] = $this->config->get('nivo_slider_featured');
		$this->data['nivo_slider_effect'] = $this->config->get('nivo_slider_effect');
		$this->data['nivo_slider_slices'] = $this->config->get('nivo_slider_slices');
		$this->data['nivo_slider_box_cols'] = $this->config->get('nivo_slider_box_cols');
		$this->data['nivo_slider_box_rows'] = $this->config->get('nivo_slider_box_rows');
		$this->data['nivo_slider_anim_speed'] = $this->config->get('nivo_slider_anim_speed');
		$this->data['nivo_slider_pause_time'] = $this->config->get('nivo_slider_pause_time');
		$this->data['nivo_slider_start_slide'] = $this->config->get('nivo_slider_start_slide');
		$this->data['nivo_slider_direction_nav'] = $this->config->get('nivo_slider_direction_nav');
		$this->data['nivo_slider_direction_nav_hide'] = $this->config->get('nivo_slider_direction_nav_hide');
		$this->data['nivo_slider_control_nav'] = $this->config->get('nivo_slider_control_nav');
		$this->data['nivo_slider_control_nav_thumbs'] = $this->config->get('nivo_slider_control_nav_thumbs');
		$this->data['nivo_slider_control_nav_thumbs_from_rel'] = $this->config->get('nivo_slider_control_nav_thumbs_from_rel');
		$this->data['nivo_slider_control_nav_thumbs_search'] = $this->config->get('nivo_slider_control_nav_thumbs_search');
		$this->data['nivo_slider_control_nav_thumbs_replace'] = $this->config->get('nivo_slider_control_nav_thumbs_replace');
		$this->data['nivo_slider_keyboard_nav'] = $this->config->get('nivo_slider_keyboard_nav');
		$this->data['nivo_slider_pause_on_hover'] = $this->config->get('nivo_slider_pause_on_hover');
		$this->data['nivo_slider_manual_advance'] = $this->config->get('nivo_slider_manual_advance');
		$this->data['nivo_slider_caption_opacity'] = $this->config->get('nivo_slider_caption_opacity');
		$this->data['nivo_slider_prev_text'] = $this->config->get('nivo_slider_prev_text');
		$this->data['nivo_slider_next_text'] = $this->config->get('nivo_slider_next_text');
		$this->data['nivo_slider_random_start'] = $this->config->get('nivo_slider_random_start');
		
		$this->data['width'] = $setting['width'];
		$this->data['height'] = $setting['height'];
		
		$this->data['banners'] = array();
		
		$results = $this->model_design_banner->getBanner($setting['banner_id']);
		  
		foreach ($results as $result) {
			if (file_exists(DIR_IMAGE . $result['image'])) {
				$this->data['banners'][] = array(
					'title' => $result['title'],
					'link'  => $result['link'],
					'image' => $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height'])
				);
			}
		}
		
		$this->data['module'] = $module++;
						
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/nivo_slider.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/nivo_slider.tpl';
		} else {
			$this->template = 'default/template/module/nivo_slider.tpl';
		}
		
		$this->render();
	}
}
?>